home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / gcc.info-26 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  49.9 KB  |  1,108 lines

  1. This is Info file gcc.info, produced by Makeinfo version 1.68 from the
  2. input file ./gcc.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * gcc: (gcc).                  The GNU Compiler Collection.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU compiler.
  9.  
  10.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  11. Boston, MA 02111-1307 USA
  12.  
  13.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  14. 1999, 2000 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License" and "Funding
  23. for Free Software" are included exactly as in the original, and
  24. provided that the entire resulting derived work is distributed under
  25. the terms of a permission notice identical to this one.
  26.  
  27.    Permission is granted to copy and distribute translations of this
  28. manual into another language, under the above conditions for modified
  29. versions, except that the sections entitled "GNU General Public
  30. License" and "Funding for Free Software", and this permission notice,
  31. may be included in translations approved by the Free Software Foundation
  32. instead of in the original English.
  33.  
  34. 
  35. File: gcc.info,  Node: Sections,  Next: PIC,  Prev: Costs,  Up: Target Macros
  36.  
  37. Dividing the Output into Sections (Texts, Data, ...)
  38. ====================================================
  39.  
  40.    An object file is divided into sections containing different types of
  41. data.  In the most common case, there are three sections: the "text
  42. section", which holds instructions and read-only data; the "data
  43. section", which holds initialized writable data; and the "bss section",
  44. which holds uninitialized data.  Some systems have other kinds of
  45. sections.
  46.  
  47.    The compiler must tell the assembler when to switch sections.  These
  48. macros control what commands to output to tell the assembler this.  You
  49. can also define additional sections.
  50.  
  51. `TEXT_SECTION_ASM_OP'
  52.      A C expression whose value is a string containing the assembler
  53.      operation that should precede instructions and read-only data.
  54.      Normally `".text"' is right.
  55.  
  56. `DATA_SECTION_ASM_OP'
  57.      A C expression whose value is a string containing the assembler
  58.      operation to identify the following data as writable initialized
  59.      data.  Normally `".data"' is right.
  60.  
  61. `SHARED_SECTION_ASM_OP'
  62.      If defined, a C expression whose value is a string containing the
  63.      assembler operation to identify the following data as shared data.
  64.      If not defined, `DATA_SECTION_ASM_OP' will be used.
  65.  
  66. `BSS_SECTION_ASM_OP'
  67.      If defined, a C expression whose value is a string containing the
  68.      assembler operation to identify the following data as
  69.      uninitialized global data.  If not defined, and neither
  70.      `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
  71.      uninitialized global data will be output in the data section if
  72.      `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
  73.      used.
  74.  
  75. `SHARED_BSS_SECTION_ASM_OP'
  76.      If defined, a C expression whose value is a string containing the
  77.      assembler operation to identify the following data as
  78.      uninitialized global shared data.  If not defined, and
  79.      `BSS_SECTION_ASM_OP' is, the latter will be used.
  80.  
  81. `INIT_SECTION_ASM_OP'
  82.      If defined, a C expression whose value is a string containing the
  83.      assembler operation to identify the following data as
  84.      initialization code.  If not defined, GNU CC will assume such a
  85.      section does not exist.
  86.  
  87. `EXTRA_SECTIONS'
  88.      A list of names for sections other than the standard two, which are
  89.      `in_text' and `in_data'.  You need not define this macro on a
  90.      system with no other sections (that GCC needs to use).
  91.  
  92. `EXTRA_SECTION_FUNCTIONS'
  93.      One or more functions to be defined in `varasm.c'.  These
  94.      functions should do jobs analogous to those of `text_section' and
  95.      `data_section', for your additional sections.  Do not define this
  96.      macro if you do not define `EXTRA_SECTIONS'.
  97.  
  98. `READONLY_DATA_SECTION'
  99.      On most machines, read-only variables, constants, and jump tables
  100.      are placed in the text section.  If this is not the case on your
  101.      machine, this macro should be defined to be the name of a function
  102.      (either `data_section' or a function defined in `EXTRA_SECTIONS')
  103.      that switches to the section to be used for read-only items.
  104.  
  105.      If these items should be placed in the text section, this macro
  106.      should not be defined.
  107.  
  108. `SELECT_SECTION (EXP, RELOC)'
  109.      A C statement or statements to switch to the appropriate section
  110.      for output of EXP.  You can assume that EXP is either a `VAR_DECL'
  111.      node or a constant of some sort.  RELOC indicates whether the
  112.      initial value of EXP requires link-time relocations.  Select the
  113.      section by calling `text_section' or one of the alternatives for
  114.      other sections.
  115.  
  116.      Do not define this macro if you put all read-only variables and
  117.      constants in the read-only data section (usually the text section).
  118.  
  119. `SELECT_RTX_SECTION (MODE, RTX)'
  120.      A C statement or statements to switch to the appropriate section
  121.      for output of RTX in mode MODE.  You can assume that RTX is some
  122.      kind of constant in RTL.  The argument MODE is redundant except in
  123.      the case of a `const_int' rtx.  Select the section by calling
  124.      `text_section' or one of the alternatives for other sections.
  125.  
  126.      Do not define this macro if you put all constants in the read-only
  127.      data section.
  128.  
  129. `JUMP_TABLES_IN_TEXT_SECTION'
  130.      Define this macro to be an expression with a non-zero value if jump
  131.      tables (for `tablejump' insns) should be output in the text
  132.      section, along with the assembler instructions.  Otherwise, the
  133.      readonly data section is used.
  134.  
  135.      This macro is irrelevant if there is no separate readonly data
  136.      section.
  137.  
  138. `ENCODE_SECTION_INFO (DECL)'
  139.      Define this macro if references to a symbol must be treated
  140.      differently depending on something about the variable or function
  141.      named by the symbol (such as what section it is in).
  142.  
  143.      The macro definition, if any, is executed immediately after the
  144.      rtl for DECL has been created and stored in `DECL_RTL (DECL)'.
  145.      The value of the rtl will be a `mem' whose address is a
  146.      `symbol_ref'.
  147.  
  148.      The usual thing for this macro to do is to record a flag in the
  149.      `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  150.      name string in the `symbol_ref' (if one bit is not enough
  151.      information).
  152.  
  153. `STRIP_NAME_ENCODING (VAR, SYM_NAME)'
  154.      Decode SYM_NAME and store the real name part in VAR, sans the
  155.      characters that encode section info.  Define this macro if
  156.      `ENCODE_SECTION_INFO' alters the symbol's name string.
  157.  
  158. `UNIQUE_SECTION_P (DECL)'
  159.      A C expression which evaluates to true if DECL should be placed
  160.      into a unique section for some target-specific reason.  If you do
  161.      not define this macro, the default is `0'.  Note that the flag
  162.      `-ffunction-sections' will also cause functions to be placed into
  163.      unique sections.
  164.  
  165. `UNIQUE_SECTION (DECL, RELOC)'
  166.      A C statement to build up a unique section name, expressed as a
  167.      STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'.
  168.      RELOC indicates whether the initial value of EXP requires
  169.      link-time relocations.  If you do not define this macro, GNU CC
  170.      will use the symbol name prefixed by `.' as the section name.
  171.  
  172. 
  173. File: gcc.info,  Node: PIC,  Next: Assembler Format,  Prev: Sections,  Up: Target Macros
  174.  
  175. Position Independent Code
  176. =========================
  177.  
  178.    This section describes macros that help implement generation of
  179. position independent code.  Simply defining these macros is not enough
  180. to generate valid PIC; you must also add support to the macros
  181. `GO_IF_LEGITIMATE_ADDRESS' and `PRINT_OPERAND_ADDRESS', as well as
  182. `LEGITIMIZE_ADDRESS'.  You must modify the definition of `movsi' to do
  183. something appropriate when the source operand contains a symbolic
  184. address.  You may also need to alter the handling of switch statements
  185. so that they use relative addresses.
  186.  
  187. `PIC_OFFSET_TABLE_REGNUM'
  188.      The register number of the register used to address a table of
  189.      static data addresses in memory.  In some cases this register is
  190.      defined by a processor's "application binary interface" (ABI).
  191.      When this macro is defined, RTL is generated for this register
  192.      once, as with the stack pointer and frame pointer registers.  If
  193.      this macro is not defined, it is up to the machine-dependent files
  194.      to allocate such a register (if necessary).
  195.  
  196. `PIC_OFFSET_TABLE_REG_CALL_CLOBBERED'
  197.      Define this macro if the register defined by
  198.      `PIC_OFFSET_TABLE_REGNUM' is clobbered by calls.  Do not define
  199.      this macro if `PIC_OFFSET_TABLE_REGNUM' is not defined.
  200.  
  201. `FINALIZE_PIC'
  202.      By generating position-independent code, when two different
  203.      programs (A and B) share a common library (libC.a), the text of
  204.      the library can be shared whether or not the library is linked at
  205.      the same address for both programs.  In some of these
  206.      environments, position-independent code requires not only the use
  207.      of different addressing modes, but also special code to enable the
  208.      use of these addressing modes.
  209.  
  210.      The `FINALIZE_PIC' macro serves as a hook to emit these special
  211.      codes once the function is being compiled into assembly code, but
  212.      not before.  (It is not done before, because in the case of
  213.      compiling an inline function, it would lead to multiple PIC
  214.      prologues being included in functions which used inline functions
  215.      and were compiled to assembly language.)
  216.  
  217. `LEGITIMATE_PIC_OPERAND_P (X)'
  218.      A C expression that is nonzero if X is a legitimate immediate
  219.      operand on the target machine when generating position independent
  220.      code.  You can assume that X satisfies `CONSTANT_P', so you need
  221.      not check this.  You can also assume FLAG_PIC is true, so you need
  222.      not check it either.  You need not define this macro if all
  223.      constants (including `SYMBOL_REF') can be immediate operands when
  224.      generating position independent code.
  225.  
  226. 
  227. File: gcc.info,  Node: Assembler Format,  Next: Debugging Info,  Prev: PIC,  Up: Target Macros
  228.  
  229. Defining the Output Assembler Language
  230. ======================================
  231.  
  232.    This section describes macros whose principal purpose is to describe
  233. how to write instructions in assembler language-rather than what the
  234. instructions do.
  235.  
  236. * Menu:
  237.  
  238. * File Framework::       Structural information for the assembler file.
  239. * Data Output::          Output of constants (numbers, strings, addresses).
  240. * Uninitialized Data::   Output of uninitialized variables.
  241. * Label Output::         Output and generation of labels.
  242. * Initialization::       General principles of initialization
  243.                and termination routines.
  244. * Macros for Initialization::
  245.              Specific macros that control the handling of
  246.                initialization and termination routines.
  247. * Instruction Output::   Output of actual instructions.
  248. * Dispatch Tables::      Output of jump tables.
  249. * Exception Region Output:: Output of exception region code.
  250. * Alignment Output::     Pseudo ops for alignment and skipping data.
  251.  
  252. 
  253. File: gcc.info,  Node: File Framework,  Next: Data Output,  Up: Assembler Format
  254.  
  255. The Overall Framework of an Assembler File
  256. ------------------------------------------
  257.  
  258.    This describes the overall framework of an assembler file.
  259.  
  260. `ASM_FILE_START (STREAM)'
  261.      A C expression which outputs to the stdio stream STREAM some
  262.      appropriate text to go at the start of an assembler file.
  263.  
  264.      Normally this macro is defined to output a line containing
  265.      `#NO_APP', which is a comment that has no effect on most
  266.      assemblers but tells the GNU assembler that it can save time by not
  267.      checking for certain assembler constructs.
  268.  
  269.      On systems that use SDB, it is necessary to output certain
  270.      commands; see `attasm.h'.
  271.  
  272. `ASM_FILE_END (STREAM)'
  273.      A C expression which outputs to the stdio stream STREAM some
  274.      appropriate text to go at the end of an assembler file.
  275.  
  276.      If this macro is not defined, the default is to output nothing
  277.      special at the end of the file.  Most systems don't require any
  278.      definition.
  279.  
  280.      On systems that use SDB, it is necessary to output certain
  281.      commands; see `attasm.h'.
  282.  
  283. `ASM_IDENTIFY_GCC (FILE)'
  284.      A C statement to output assembler commands which will identify the
  285.      object file as having been compiled with GNU CC (or another GNU
  286.      compiler).
  287.  
  288.      If you don't define this macro, the string `gcc_compiled.:' is
  289.      output.  This string is calculated to define a symbol which, on
  290.      BSD systems, will never be defined for any other reason.  GDB
  291.      checks for the presence of this symbol when reading the symbol
  292.      table of an executable.
  293.  
  294.      On non-BSD systems, you must arrange communication with GDB in
  295.      some other fashion.  If GDB is not used on your system, you can
  296.      define this macro with an empty body.
  297.  
  298. `ASM_COMMENT_START'
  299.      A C string constant describing how to begin a comment in the target
  300.      assembler language.  The compiler assumes that the comment will
  301.      end at the end of the line.
  302.  
  303. `ASM_APP_ON'
  304.      A C string constant for text to be output before each `asm'
  305.      statement or group of consecutive ones.  Normally this is
  306.      `"#APP"', which is a comment that has no effect on most assemblers
  307.      but tells the GNU assembler that it must check the lines that
  308.      follow for all valid assembler constructs.
  309.  
  310. `ASM_APP_OFF'
  311.      A C string constant for text to be output after each `asm'
  312.      statement or group of consecutive ones.  Normally this is
  313.      `"#NO_APP"', which tells the GNU assembler to resume making the
  314.      time-saving assumptions that are valid for ordinary compiler
  315.      output.
  316.  
  317. `ASM_OUTPUT_SOURCE_FILENAME (STREAM, NAME)'
  318.      A C statement to output COFF information or DWARF debugging
  319.      information which indicates that filename NAME is the current
  320.      source file to the stdio stream STREAM.
  321.  
  322.      This macro need not be defined if the standard form of output for
  323.      the file format in use is appropriate.
  324.  
  325. `OUTPUT_QUOTED_STRING (STREAM, NAME)'
  326.      A C statement to output the string STRING to the stdio stream
  327.      STREAM.  If you do not call the function `output_quoted_string' in
  328.      your config files, GNU CC will only call it to output filenames to
  329.      the assembler source.  So you can use it to canonicalize the format
  330.      of the filename using this macro.
  331.  
  332. `ASM_OUTPUT_SOURCE_LINE (STREAM, LINE)'
  333.      A C statement to output DBX or SDB debugging information before
  334.      code for line number LINE of the current source file to the stdio
  335.      stream STREAM.
  336.  
  337.      This macro need not be defined if the standard form of debugging
  338.      information for the debugger in use is appropriate.
  339.  
  340. `ASM_OUTPUT_IDENT (STREAM, STRING)'
  341.      A C statement to output something to the assembler file to handle a
  342.      `#ident' directive containing the text STRING.  If this macro is
  343.      not defined, nothing is output for a `#ident' directive.
  344.  
  345. `ASM_OUTPUT_SECTION_NAME (STREAM, DECL, NAME, RELOC)'
  346.      A C statement to output something to the assembler file to switch
  347.      to section NAME for object DECL which is either a `FUNCTION_DECL',
  348.      a `VAR_DECL' or `NULL_TREE'.  RELOC indicates whether the initial
  349.      value of EXP requires link-time relocations.  Some target formats
  350.      do not support arbitrary sections.  Do not define this macro in
  351.      such cases.
  352.  
  353.      At present this macro is only used to support section attributes.
  354.      When this macro is undefined, section attributes are disabled.
  355.  
  356. `OBJC_PROLOGUE'
  357.      A C statement to output any assembler statements which are
  358.      required to precede any Objective C object definitions or message
  359.      sending.  The statement is executed only when compiling an
  360.      Objective C program.
  361.  
  362. 
  363. File: gcc.info,  Node: Data Output,  Next: Uninitialized Data,  Prev: File Framework,  Up: Assembler Format
  364.  
  365. Output of Data
  366. --------------
  367.  
  368.    This describes data output.
  369.  
  370. `ASM_OUTPUT_LONG_DOUBLE (STREAM, VALUE)'
  371. `ASM_OUTPUT_DOUBLE (STREAM, VALUE)'
  372. `ASM_OUTPUT_FLOAT (STREAM, VALUE)'
  373. `ASM_OUTPUT_THREE_QUARTER_FLOAT (STREAM, VALUE)'
  374. `ASM_OUTPUT_SHORT_FLOAT (STREAM, VALUE)'
  375. `ASM_OUTPUT_BYTE_FLOAT (STREAM, VALUE)'
  376.      A C statement to output to the stdio stream STREAM an assembler
  377.      instruction to assemble a floating-point constant of `TFmode',
  378.      `DFmode', `SFmode', `TQFmode', `HFmode', or `QFmode',
  379.      respectively, whose value is VALUE.  VALUE will be a C expression
  380.      of type `REAL_VALUE_TYPE'.  Macros such as
  381.      `REAL_VALUE_TO_TARGET_DOUBLE' are useful for writing these
  382.      definitions.
  383.  
  384. `ASM_OUTPUT_QUADRUPLE_INT (STREAM, EXP)'
  385. `ASM_OUTPUT_DOUBLE_INT (STREAM, EXP)'
  386. `ASM_OUTPUT_INT (STREAM, EXP)'
  387. `ASM_OUTPUT_SHORT (STREAM, EXP)'
  388. `ASM_OUTPUT_CHAR (STREAM, EXP)'
  389.      A C statement to output to the stdio stream STREAM an assembler
  390.      instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes,
  391.      respectively, whose value is VALUE.  The argument EXP will be an
  392.      RTL expression which represents a constant value.  Use
  393.      `output_addr_const (STREAM, EXP)' to output this value as an
  394.      assembler expression.
  395.  
  396.      For sizes larger than `UNITS_PER_WORD', if the action of a macro
  397.      would be identical to repeatedly calling the macro corresponding to
  398.      a size of `UNITS_PER_WORD', once for each word, you need not define
  399.      the macro.
  400.  
  401. `ASM_OUTPUT_BYTE (STREAM, VALUE)'
  402.      A C statement to output to the stdio stream STREAM an assembler
  403.      instruction to assemble a single byte containing the number VALUE.
  404.  
  405. `ASM_BYTE_OP'
  406.      A C string constant giving the pseudo-op to use for a sequence of
  407.      single-byte constants.  If this macro is not defined, the default
  408.      is `"byte"'.
  409.  
  410. `ASM_OUTPUT_ASCII (STREAM, PTR, LEN)'
  411.      A C statement to output to the stdio stream STREAM an assembler
  412.      instruction to assemble a string constant containing the LEN bytes
  413.      at PTR.  PTR will be a C expression of type `char *' and LEN a C
  414.      expression of type `int'.
  415.  
  416.      If the assembler has a `.ascii' pseudo-op as found in the Berkeley
  417.      Unix assembler, do not define the macro `ASM_OUTPUT_ASCII'.
  418.  
  419. `CONSTANT_POOL_BEFORE_FUNCTION'
  420.      You may define this macro as a C expression.  You should define the
  421.      expression to have a non-zero value if GNU CC should output the
  422.      constant pool for a function before the code for the function, or
  423.      a zero value if GNU CC should output the constant pool after the
  424.      function.  If you do not define this macro, the usual case, GNU CC
  425.      will output the constant pool before the function.
  426.  
  427. `ASM_OUTPUT_POOL_PROLOGUE (FILE FUNNAME FUNDECL SIZE)'
  428.      A C statement to output assembler commands to define the start of
  429.      the constant pool for a function.  FUNNAME is a string giving the
  430.      name of the function.  Should the return type of the function be
  431.      required, it can be obtained via FUNDECL.  SIZE is the size, in
  432.      bytes, of the constant pool that will be written immediately after
  433.      this call.
  434.  
  435.      If no constant-pool prefix is required, the usual case, this macro
  436.      need not be defined.
  437.  
  438. `ASM_OUTPUT_SPECIAL_POOL_ENTRY (FILE, X, MODE, ALIGN, LABELNO, JUMPTO)'
  439.      A C statement (with or without semicolon) to output a constant in
  440.      the constant pool, if it needs special treatment.  (This macro
  441.      need not do anything for RTL expressions that can be output
  442.      normally.)
  443.  
  444.      The argument FILE is the standard I/O stream to output the
  445.      assembler code on.  X is the RTL expression for the constant to
  446.      output, and MODE is the machine mode (in case X is a `const_int').
  447.      ALIGN is the required alignment for the value X; you should
  448.      output an assembler directive to force this much alignment.
  449.  
  450.      The argument LABELNO is a number to use in an internal label for
  451.      the address of this pool entry.  The definition of this macro is
  452.      responsible for outputting the label definition at the proper
  453.      place.  Here is how to do this:
  454.  
  455.           ASM_OUTPUT_INTERNAL_LABEL (FILE, "LC", LABELNO);
  456.  
  457.      When you output a pool entry specially, you should end with a
  458.      `goto' to the label JUMPTO.  This will prevent the same pool entry
  459.      from being output a second time in the usual manner.
  460.  
  461.      You need not define this macro if it would do nothing.
  462.  
  463. `CONSTANT_AFTER_FUNCTION_P (EXP)'
  464.      Define this macro as a C expression which is nonzero if the
  465.      constant EXP, of type `tree', should be output after the code for a
  466.      function.  The compiler will normally output all constants before
  467.      the function; you need not define this macro if this is OK.
  468.  
  469. `ASM_OUTPUT_POOL_EPILOGUE (FILE FUNNAME FUNDECL SIZE)'
  470.      A C statement to output assembler commands to at the end of the
  471.      constant pool for a function.  FUNNAME is a string giving the name
  472.      of the function.  Should the return type of the function be
  473.      required, you can obtain it via FUNDECL.  SIZE is the size, in
  474.      bytes, of the constant pool that GNU CC wrote immediately before
  475.      this call.
  476.  
  477.      If no constant-pool epilogue is required, the usual case, you need
  478.      not define this macro.
  479.  
  480. `IS_ASM_LOGICAL_LINE_SEPARATOR (C)'
  481.      Define this macro as a C expression which is nonzero if C is used
  482.      as a logical line separator by the assembler.
  483.  
  484.      If you do not define this macro, the default is that only the
  485.      character `;' is treated as a logical line separator.
  486.  
  487. `ASM_OPEN_PAREN'
  488. `ASM_CLOSE_PAREN'
  489.      These macros are defined as C string constant, describing the
  490.      syntax in the assembler for grouping arithmetic expressions.  The
  491.      following definitions are correct for most assemblers:
  492.  
  493.           #define ASM_OPEN_PAREN "("
  494.           #define ASM_CLOSE_PAREN ")"
  495.  
  496.      These macros are provided by `real.h' for writing the definitions
  497. of `ASM_OUTPUT_DOUBLE' and the like:
  498.  
  499. `REAL_VALUE_TO_TARGET_SINGLE (X, L)'
  500. `REAL_VALUE_TO_TARGET_DOUBLE (X, L)'
  501. `REAL_VALUE_TO_TARGET_LONG_DOUBLE (X, L)'
  502.      These translate X, of type `REAL_VALUE_TYPE', to the target's
  503.      floating point representation, and store its bit pattern in the
  504.      array of `long int' whose address is L.  The number of elements in
  505.      the output array is determined by the size of the desired target
  506.      floating point data type: 32 bits of it go in each `long int' array
  507.      element.  Each array element holds 32 bits of the result, even if
  508.      `long int' is wider than 32 bits on the host machine.
  509.  
  510.      The array element values are designed so that you can print them
  511.      out using `fprintf' in the order they should appear in the target
  512.      machine's memory.
  513.  
  514. `REAL_VALUE_TO_DECIMAL (X, FORMAT, STRING)'
  515.      This macro converts X, of type `REAL_VALUE_TYPE', to a decimal
  516.      number and stores it as a string into STRING.  You must pass, as
  517.      STRING, the address of a long enough block of space to hold the
  518.      result.
  519.  
  520.      The argument FORMAT is a `printf'-specification that serves as a
  521.      suggestion for how to format the output string.
  522.  
  523. 
  524. File: gcc.info,  Node: Uninitialized Data,  Next: Label Output,  Prev: Data Output,  Up: Assembler Format
  525.  
  526. Output of Uninitialized Variables
  527. ---------------------------------
  528.  
  529.    Each of the macros in this section is used to do the whole job of
  530. outputting a single uninitialized variable.
  531.  
  532. `ASM_OUTPUT_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  533.      A C statement (sans semicolon) to output to the stdio stream
  534.      STREAM the assembler definition of a common-label named NAME whose
  535.      size is SIZE bytes.  The variable ROUNDED is the size rounded up
  536.      to whatever alignment the caller wants.
  537.  
  538.      Use the expression `assemble_name (STREAM, NAME)' to output the
  539.      name itself; before and after that, output the additional
  540.      assembler syntax for defining the name, and a newline.
  541.  
  542.      This macro controls how the assembler definitions of uninitialized
  543.      common global variables are output.
  544.  
  545. `ASM_OUTPUT_ALIGNED_COMMON (STREAM, NAME, SIZE, ALIGNMENT)'
  546.      Like `ASM_OUTPUT_COMMON' except takes the required alignment as a
  547.      separate, explicit argument.  If you define this macro, it is used
  548.      in place of `ASM_OUTPUT_COMMON', and gives you more flexibility in
  549.      handling the required alignment of the variable.  The alignment is
  550.      specified as the number of bits.
  551.  
  552. `ASM_OUTPUT_ALIGNED_DECL_COMMON (STREAM, DECL, NAME, SIZE, ALIGNMENT)'
  553.      Like `ASM_OUTPUT_ALIGNED_COMMON' except that DECL of the variable
  554.      to be output, if there is one, or `NULL_TREE' if there is not
  555.      corresponding variable.  If you define this macro, GNU CC wil use
  556.      it in place of both `ASM_OUTPUT_COMMON' and
  557.      `ASM_OUTPUT_ALIGNED_COMMON'.  Define this macro when you need to
  558.      see the variable's decl in order to chose what to output.
  559.  
  560. `ASM_OUTPUT_SHARED_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  561.      If defined, it is similar to `ASM_OUTPUT_COMMON', except that it
  562.      is used when NAME is shared.  If not defined, `ASM_OUTPUT_COMMON'
  563.      will be used.
  564.  
  565. `ASM_OUTPUT_BSS (STREAM, DECL, NAME, SIZE, ROUNDED)'
  566.      A C statement (sans semicolon) to output to the stdio stream
  567.      STREAM the assembler definition of uninitialized global DECL named
  568.      NAME whose size is SIZE bytes.  The variable ROUNDED is the size
  569.      rounded up to whatever alignment the caller wants.
  570.  
  571.      Try to use function `asm_output_bss' defined in `varasm.c' when
  572.      defining this macro.  If unable, use the expression `assemble_name
  573.      (STREAM, NAME)' to output the name itself; before and after that,
  574.      output the additional assembler syntax for defining the name, and
  575.      a newline.
  576.  
  577.      This macro controls how the assembler definitions of uninitialized
  578.      global variables are output.  This macro exists to properly
  579.      support languages like `c++' which do not have `common' data.
  580.      However, this macro currently is not defined for all targets.  If
  581.      this macro and `ASM_OUTPUT_ALIGNED_BSS' are not defined then
  582.      `ASM_OUTPUT_COMMON' or `ASM_OUTPUT_ALIGNED_COMMON' or
  583.      `ASM_OUTPUT_ALIGNED_DECL_COMMON' is used.
  584.  
  585. `ASM_OUTPUT_ALIGNED_BSS (STREAM, DECL, NAME, SIZE, ALIGNMENT)'
  586.      Like `ASM_OUTPUT_BSS' except takes the required alignment as a
  587.      separate, explicit argument.  If you define this macro, it is used
  588.      in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
  589.      handling the required alignment of the variable.  The alignment is
  590.      specified as the number of bits.
  591.  
  592.      Try to use function `asm_output_aligned_bss' defined in file
  593.      `varasm.c' when defining this macro.
  594.  
  595. `ASM_OUTPUT_SHARED_BSS (STREAM, DECL, NAME, SIZE, ROUNDED)'
  596.      If defined, it is similar to `ASM_OUTPUT_BSS', except that it is
  597.      used when NAME is shared.  If not defined, `ASM_OUTPUT_BSS' will
  598.      be used.
  599.  
  600. `ASM_OUTPUT_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  601.      A C statement (sans semicolon) to output to the stdio stream
  602.      STREAM the assembler definition of a local-common-label named NAME
  603.      whose size is SIZE bytes.  The variable ROUNDED is the size
  604.      rounded up to whatever alignment the caller wants.
  605.  
  606.      Use the expression `assemble_name (STREAM, NAME)' to output the
  607.      name itself; before and after that, output the additional
  608.      assembler syntax for defining the name, and a newline.
  609.  
  610.      This macro controls how the assembler definitions of uninitialized
  611.      static variables are output.
  612.  
  613. `ASM_OUTPUT_ALIGNED_LOCAL (STREAM, NAME, SIZE, ALIGNMENT)'
  614.      Like `ASM_OUTPUT_LOCAL' except takes the required alignment as a
  615.      separate, explicit argument.  If you define this macro, it is used
  616.      in place of `ASM_OUTPUT_LOCAL', and gives you more flexibility in
  617.      handling the required alignment of the variable.  The alignment is
  618.      specified as the number of bits.
  619.  
  620. `ASM_OUTPUT_ALIGNED_DECL_LOCAL (STREAM, DECL, NAME, SIZE, ALIGNMENT)'
  621.      Like `ASM_OUTPUT_ALIGNED_DECL' except that DECL of the variable to
  622.      be output, if there is one, or `NULL_TREE' if there is not
  623.      corresponding variable.  If you define this macro, GNU CC wil use
  624.      it in place of both `ASM_OUTPUT_DECL' and
  625.      `ASM_OUTPUT_ALIGNED_DECL'.  Define this macro when you need to see
  626.      the variable's decl in order to chose what to output.
  627.  
  628. `ASM_OUTPUT_SHARED_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  629.      If defined, it is similar to `ASM_OUTPUT_LOCAL', except that it is
  630.      used when NAME is shared.  If not defined, `ASM_OUTPUT_LOCAL' will
  631.      be used.
  632.  
  633. 
  634. File: gcc.info,  Node: Label Output,  Next: Initialization,  Prev: Uninitialized Data,  Up: Assembler Format
  635.  
  636. Output and Generation of Labels
  637. -------------------------------
  638.  
  639.    This is about outputting labels.
  640.  
  641. `ASM_OUTPUT_LABEL (STREAM, NAME)'
  642.      A C statement (sans semicolon) to output to the stdio stream
  643.      STREAM the assembler definition of a label named NAME.  Use the
  644.      expression `assemble_name (STREAM, NAME)' to output the name
  645.      itself; before and after that, output the additional assembler
  646.      syntax for defining the name, and a newline.
  647.  
  648. `ASM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL)'
  649.      A C statement (sans semicolon) to output to the stdio stream
  650.      STREAM any text necessary for declaring the name NAME of a
  651.      function which is being defined.  This macro is responsible for
  652.      outputting the label definition (perhaps using
  653.      `ASM_OUTPUT_LABEL').  The argument DECL is the `FUNCTION_DECL'
  654.      tree node representing the function.
  655.  
  656.      If this macro is not defined, then the function name is defined in
  657.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  658.  
  659. `ASM_DECLARE_FUNCTION_SIZE (STREAM, NAME, DECL)'
  660.      A C statement (sans semicolon) to output to the stdio stream
  661.      STREAM any text necessary for declaring the size of a function
  662.      which is being defined.  The argument NAME is the name of the
  663.      function.  The argument DECL is the `FUNCTION_DECL' tree node
  664.      representing the function.
  665.  
  666.      If this macro is not defined, then the function size is not
  667.      defined.
  668.  
  669. `ASM_DECLARE_OBJECT_NAME (STREAM, NAME, DECL)'
  670.      A C statement (sans semicolon) to output to the stdio stream
  671.      STREAM any text necessary for declaring the name NAME of an
  672.      initialized variable which is being defined.  This macro must
  673.      output the label definition (perhaps using `ASM_OUTPUT_LABEL').
  674.      The argument DECL is the `VAR_DECL' tree node representing the
  675.      variable.
  676.  
  677.      If this macro is not defined, then the variable name is defined in
  678.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  679.  
  680. `ASM_FINISH_DECLARE_OBJECT (STREAM, DECL, TOPLEVEL, ATEND)'
  681.      A C statement (sans semicolon) to finish up declaring a variable
  682.      name once the compiler has processed its initializer fully and
  683.      thus has had a chance to determine the size of an array when
  684.      controlled by an initializer.  This is used on systems where it's
  685.      necessary to declare something about the size of the object.
  686.  
  687.      If you don't define this macro, that is equivalent to defining it
  688.      to do nothing.
  689.  
  690. `ASM_GLOBALIZE_LABEL (STREAM, NAME)'
  691.      A C statement (sans semicolon) to output to the stdio stream
  692.      STREAM some commands that will make the label NAME global; that
  693.      is, available for reference from other files.  Use the expression
  694.      `assemble_name (STREAM, NAME)' to output the name itself; before
  695.      and after that, output the additional assembler syntax for making
  696.      that name global, and a newline.
  697.  
  698. `ASM_WEAKEN_LABEL'
  699.      A C statement (sans semicolon) to output to the stdio stream
  700.      STREAM some commands that will make the label NAME weak; that is,
  701.      available for reference from other files but only used if no other
  702.      definition is available.  Use the expression `assemble_name
  703.      (STREAM, NAME)' to output the name itself; before and after that,
  704.      output the additional assembler syntax for making that name weak,
  705.      and a newline.
  706.  
  707.      If you don't define this macro, GNU CC will not support weak
  708.      symbols and you should not define the `SUPPORTS_WEAK' macro.
  709.  
  710. `SUPPORTS_WEAK'
  711.      A C expression which evaluates to true if the target supports weak
  712.      symbols.
  713.  
  714.      If you don't define this macro, `defaults.h' provides a default
  715.      definition.  If `ASM_WEAKEN_LABEL' is defined, the default
  716.      definition is `1'; otherwise, it is `0'.  Define this macro if you
  717.      want to control weak symbol support with a compiler flag such as
  718.      `-melf'.
  719.  
  720. `MAKE_DECL_ONE_ONLY'
  721.      A C statement (sans semicolon) to mark DECL to be emitted as a
  722.      public symbol such that extra copies in multiple translation units
  723.      will be discarded by the linker.  Define this macro if your object
  724.      file format provides support for this concept, such as the `COMDAT'
  725.      section flags in the Microsoft Windows PE/COFF format, and this
  726.      support requires changes to DECL, such as putting it in a separate
  727.      section.
  728.  
  729. `SUPPORTS_ONE_ONLY'
  730.      A C expression which evaluates to true if the target supports
  731.      one-only semantics.
  732.  
  733.      If you don't define this macro, `varasm.c' provides a default
  734.      definition.  If `MAKE_DECL_ONE_ONLY' is defined, the default
  735.      definition is `1'; otherwise, it is `0'.  Define this macro if you
  736.      want to control one-only symbol support with a compiler flag, or if
  737.      setting the `DECL_ONE_ONLY' flag is enough to mark a declaration to
  738.      be emitted as one-only.
  739.  
  740. `ASM_OUTPUT_EXTERNAL (STREAM, DECL, NAME)'
  741.      A C statement (sans semicolon) to output to the stdio stream
  742.      STREAM any text necessary for declaring the name of an external
  743.      symbol named NAME which is referenced in this compilation but not
  744.      defined.  The value of DECL is the tree node for the declaration.
  745.  
  746.      This macro need not be defined if it does not need to output
  747.      anything.  The GNU assembler and most Unix assemblers don't
  748.      require anything.
  749.  
  750. `ASM_OUTPUT_EXTERNAL_LIBCALL (STREAM, SYMREF)'
  751.      A C statement (sans semicolon) to output on STREAM an assembler
  752.      pseudo-op to declare a library function name external.  The name
  753.      of the library function is given by SYMREF, which has type `rtx'
  754.      and is a `symbol_ref'.
  755.  
  756.      This macro need not be defined if it does not need to output
  757.      anything.  The GNU assembler and most Unix assemblers don't
  758.      require anything.
  759.  
  760. `ASM_OUTPUT_LABELREF (STREAM, NAME)'
  761.      A C statement (sans semicolon) to output to the stdio stream
  762.      STREAM a reference in assembler syntax to a label named NAME.
  763.      This should add `_' to the front of the name, if that is customary
  764.      on your operating system, as it is in most Berkeley Unix systems.
  765.      This macro is used in `assemble_name'.
  766.  
  767. `ASM_OUTPUT_INTERNAL_LABEL (STREAM, PREFIX, NUM)'
  768.      A C statement to output to the stdio stream STREAM a label whose
  769.      name is made from the string PREFIX and the number NUM.
  770.  
  771.      It is absolutely essential that these labels be distinct from the
  772.      labels used for user-level functions and variables.  Otherwise,
  773.      certain programs will have name conflicts with internal labels.
  774.  
  775.      It is desirable to exclude internal labels from the symbol table
  776.      of the object file.  Most assemblers have a naming convention for
  777.      labels that should be excluded; on many systems, the letter `L' at
  778.      the beginning of a label has this effect.  You should find out what
  779.      convention your system uses, and follow it.
  780.  
  781.      The usual definition of this macro is as follows:
  782.  
  783.           fprintf (STREAM, "L%s%d:\n", PREFIX, NUM)
  784.  
  785. `ASM_GENERATE_INTERNAL_LABEL (STRING, PREFIX, NUM)'
  786.      A C statement to store into the string STRING a label whose name
  787.      is made from the string PREFIX and the number NUM.
  788.  
  789.      This string, when output subsequently by `assemble_name', should
  790.      produce the output that `ASM_OUTPUT_INTERNAL_LABEL' would produce
  791.      with the same PREFIX and NUM.
  792.  
  793.      If the string begins with `*', then `assemble_name' will output
  794.      the rest of the string unchanged.  It is often convenient for
  795.      `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way.  If the
  796.      string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to
  797.      output the string, and may change it.  (Of course,
  798.      `ASM_OUTPUT_LABELREF' is also part of your machine description, so
  799.      you should know what it does on your machine.)
  800.  
  801. `ASM_FORMAT_PRIVATE_NAME (OUTVAR, NAME, NUMBER)'
  802.      A C expression to assign to OUTVAR (which is a variable of type
  803.      `char *') a newly allocated string made from the string NAME and
  804.      the number NUMBER, with some suitable punctuation added.  Use
  805.      `alloca' to get space for the string.
  806.  
  807.      The string will be used as an argument to `ASM_OUTPUT_LABELREF' to
  808.      produce an assembler label for an internal static variable whose
  809.      name is NAME.  Therefore, the string must be such as to result in
  810.      valid assembler code.  The argument NUMBER is different each time
  811.      this macro is executed; it prevents conflicts between
  812.      similarly-named internal static variables in different scopes.
  813.  
  814.      Ideally this string should not be a valid C identifier, to prevent
  815.      any conflict with the user's own symbols.  Most assemblers allow
  816.      periods or percent signs in assembler symbols; putting at least
  817.      one of these between the name and the number will suffice.
  818.  
  819. `ASM_OUTPUT_DEF (STREAM, NAME, VALUE)'
  820.      A C statement to output to the stdio stream STREAM assembler code
  821.      which defines (equates) the symbol NAME to have the value VALUE.
  822.  
  823.      If SET_ASM_OP is defined, a default definition is provided which is
  824.      correct for most systems.
  825.  
  826. `ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (STREAM, SYMBOL, HIGH, LOW)'
  827.      A C statement to output to the stdio stream STREAM assembler code
  828.      which defines (equates) the symbol SYMBOL to have a value equal to
  829.      the difference of the two symbols HIGH and LOW, i.e.  HIGH minus
  830.      LOW.  GNU CC guarantees that the symbols HIGH and LOW are already
  831.      known by the assembler so that the difference resolves into a
  832.      constant.
  833.  
  834.      If SET_ASM_OP is defined, a default definition is provided which is
  835.      correct for most systems.
  836.  
  837. `ASM_OUTPUT_WEAK_ALIAS (STREAM, NAME, VALUE)'
  838.      A C statement to output to the stdio stream STREAM assembler code
  839.      which defines (equates) the weak symbol NAME to have the value
  840.      VALUE.
  841.  
  842.      Define this macro if the target only supports weak aliases; define
  843.      ASM_OUTPUT_DEF instead if possible.
  844.  
  845. `OBJC_GEN_METHOD_LABEL (BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME)'
  846.      Define this macro to override the default assembler names used for
  847.      Objective C methods.
  848.  
  849.      The default name is a unique method number followed by the name of
  850.      the class (e.g. `_1_Foo').  For methods in categories, the name of
  851.      the category is also included in the assembler name (e.g.
  852.      `_1_Foo_Bar').
  853.  
  854.      These names are safe on most systems, but make debugging difficult
  855.      since the method's selector is not present in the name.
  856.      Therefore, particular systems define other ways of computing names.
  857.  
  858.      BUF is an expression of type `char *' which gives you a buffer in
  859.      which to store the name; its length is as long as CLASS_NAME,
  860.      CAT_NAME and SEL_NAME put together, plus 50 characters extra.
  861.  
  862.      The argument IS_INST specifies whether the method is an instance
  863.      method or a class method; CLASS_NAME is the name of the class;
  864.      CAT_NAME is the name of the category (or NULL if the method is not
  865.      in a category); and SEL_NAME is the name of the selector.
  866.  
  867.      On systems where the assembler can handle quoted names, you can
  868.      use this macro to provide more human-readable names.
  869.  
  870. 
  871. File: gcc.info,  Node: Initialization,  Next: Macros for Initialization,  Prev: Label Output,  Up: Assembler Format
  872.  
  873. How Initialization Functions Are Handled
  874. ----------------------------------------
  875.  
  876.    The compiled code for certain languages includes "constructors"
  877. (also called "initialization routines")--functions to initialize data
  878. in the program when the program is started.  These functions need to be
  879. called before the program is "started"--that is to say, before `main'
  880. is called.
  881.  
  882.    Compiling some languages generates "destructors" (also called
  883. "termination routines") that should be called when the program
  884. terminates.
  885.  
  886.    To make the initialization and termination functions work, the
  887. compiler must output something in the assembler code to cause those
  888. functions to be called at the appropriate time.  When you port the
  889. compiler to a new system, you need to specify how to do this.
  890.  
  891.    There are two major ways that GCC currently supports the execution of
  892. initialization and termination functions.  Each way has two variants.
  893. Much of the structure is common to all four variations.
  894.  
  895.    The linker must build two lists of these functions--a list of
  896. initialization functions, called `__CTOR_LIST__', and a list of
  897. termination functions, called `__DTOR_LIST__'.
  898.  
  899.    Each list always begins with an ignored function pointer (which may
  900. hold 0, -1, or a count of the function pointers after it, depending on
  901. the environment).  This is followed by a series of zero or more function
  902. pointers to constructors (or destructors), followed by a function
  903. pointer containing zero.
  904.  
  905.    Depending on the operating system and its executable file format,
  906. either `crtstuff.c' or `libgcc2.c' traverses these lists at startup
  907. time and exit time.  Constructors are called in reverse order of the
  908. list; destructors in forward order.
  909.  
  910.    The best way to handle static constructors works only for object file
  911. formats which provide arbitrarily-named sections.  A section is set
  912. aside for a list of constructors, and another for a list of destructors.
  913. Traditionally these are called `.ctors' and `.dtors'.  Each object file
  914. that defines an initialization function also puts a word in the
  915. constructor section to point to that function.  The linker accumulates
  916. all these words into one contiguous `.ctors' section.  Termination
  917. functions are handled similarly.
  918.  
  919.    To use this method, you need appropriate definitions of the macros
  920. `ASM_OUTPUT_CONSTRUCTOR' and `ASM_OUTPUT_DESTRUCTOR'.  Usually you can
  921. get them by including `svr4.h'.
  922.  
  923.    When arbitrary sections are available, there are two variants,
  924. depending upon how the code in `crtstuff.c' is called.  On systems that
  925. support an "init" section which is executed at program startup, parts
  926. of `crtstuff.c' are compiled into that section.  The program is linked
  927. by the `gcc' driver like this:
  928.  
  929.      ld -o OUTPUT_FILE crtbegin.o ... crtend.o -lgcc
  930.  
  931.    The head of a function (`__do_global_ctors') appears in the init
  932. section of `crtbegin.o'; the remainder of the function appears in the
  933. init section of `crtend.o'.  The linker will pull these two parts of
  934. the section together, making a whole function.  If any of the user's
  935. object files linked into the middle of it contribute code, then that
  936. code will be executed as part of the body of `__do_global_ctors'.
  937.  
  938.    To use this variant, you must define the `INIT_SECTION_ASM_OP' macro
  939. properly.
  940.  
  941.    If no init section is available, do not define
  942. `INIT_SECTION_ASM_OP'.  Then `__do_global_ctors' is built into the text
  943. section like all other functions, and resides in `libgcc.a'.  When GCC
  944. compiles any function called `main', it inserts a procedure call to
  945. `__main' as the first executable code after the function prologue.  The
  946. `__main' function, also defined in `libgcc2.c', simply calls
  947. `__do_global_ctors'.
  948.  
  949.    In file formats that don't support arbitrary sections, there are
  950. again two variants.  In the simplest variant, the GNU linker (GNU `ld')
  951. and an `a.out' format must be used.  In this case,
  952. `ASM_OUTPUT_CONSTRUCTOR' is defined to produce a `.stabs' entry of type
  953. `N_SETT', referencing the name `__CTOR_LIST__', and with the address of
  954. the void function containing the initialization code as its value.  The
  955. GNU linker recognizes this as a request to add the value to a "set";
  956. the values are accumulated, and are eventually placed in the executable
  957. as a vector in the format described above, with a leading (ignored)
  958. count and a trailing zero element.  `ASM_OUTPUT_DESTRUCTOR' is handled
  959. similarly.  Since no init section is available, the absence of
  960. `INIT_SECTION_ASM_OP' causes the compilation of `main' to call `__main'
  961. as above, starting the initialization process.
  962.  
  963.    The last variant uses neither arbitrary sections nor the GNU linker.
  964. This is preferable when you want to do dynamic linking and when using
  965. file formats which the GNU linker does not support, such as `ECOFF'.  In
  966. this case, `ASM_OUTPUT_CONSTRUCTOR' does not produce an `N_SETT'
  967. symbol; initialization and termination functions are recognized simply
  968. by their names.  This requires an extra program in the linkage step,
  969. called `collect2'.  This program pretends to be the linker, for use
  970. with GNU CC; it does its job by running the ordinary linker, but also
  971. arranges to include the vectors of initialization and termination
  972. functions.  These functions are called via `__main' as described above.
  973.  
  974.    Choosing among these configuration options has been simplified by a
  975. set of operating-system-dependent files in the `config' subdirectory.
  976. These files define all of the relevant parameters.  Usually it is
  977. sufficient to include one into your specific machine-dependent
  978. configuration file.  These files are:
  979.  
  980. `aoutos.h'
  981.      For operating systems using the `a.out' format.
  982.  
  983. `next.h'
  984.      For operating systems using the `MachO' format.
  985.  
  986. `svr3.h'
  987.      For System V Release 3 and similar systems using `COFF' format.
  988.  
  989. `svr4.h'
  990.      For System V Release 4 and similar systems using `ELF' format.
  991.  
  992. `vms.h'
  993.      For the VMS operating system.
  994.  
  995.    The following section describes the specific macros that control and
  996. customize the handling of initialization and termination functions.
  997.  
  998. 
  999. File: gcc.info,  Node: Macros for Initialization,  Next: Instruction Output,  Prev: Initialization,  Up: Assembler Format
  1000.  
  1001. Macros Controlling Initialization Routines
  1002. ------------------------------------------
  1003.  
  1004.    Here are the macros that control how the compiler handles
  1005. initialization and termination functions:
  1006.  
  1007. `INIT_SECTION_ASM_OP'
  1008.      If defined, a C string constant for the assembler operation to
  1009.      identify the following data as initialization code.  If not
  1010.      defined, GNU CC will assume such a section does not exist.  When
  1011.      you are using special sections for initialization and termination
  1012.      functions, this macro also controls how `crtstuff.c' and
  1013.      `libgcc2.c' arrange to run the initialization functions.
  1014.  
  1015. `HAS_INIT_SECTION'
  1016.      If defined, `main' will not call `__main' as described above.
  1017.      This macro should be defined for systems that control the contents
  1018.      of the init section on a symbol-by-symbol basis, such as OSF/1,
  1019.      and should not be defined explicitly for systems that support
  1020.      `INIT_SECTION_ASM_OP'.
  1021.  
  1022. `LD_INIT_SWITCH'
  1023.      If defined, a C string constant for a switch that tells the linker
  1024.      that the following symbol is an initialization routine.
  1025.  
  1026. `LD_FINI_SWITCH'
  1027.      If defined, a C string constant for a switch that tells the linker
  1028.      that the following symbol is a finalization routine.
  1029.  
  1030. `INVOKE__main'
  1031.      If defined, `main' will call `__main' despite the presence of
  1032.      `INIT_SECTION_ASM_OP'.  This macro should be defined for systems
  1033.      where the init section is not actually run automatically, but is
  1034.      still useful for collecting the lists of constructors and
  1035.      destructors.
  1036.  
  1037. `ASM_OUTPUT_CONSTRUCTOR (STREAM, NAME)'
  1038.      Define this macro as a C statement to output on the stream STREAM
  1039.      the assembler code to arrange to call the function named NAME at
  1040.      initialization time.
  1041.  
  1042.      Assume that NAME is the name of a C function generated
  1043.      automatically by the compiler.  This function takes no arguments.
  1044.      Use the function `assemble_name' to output the name NAME; this
  1045.      performs any system-specific syntactic transformations such as
  1046.      adding an underscore.
  1047.  
  1048.      If you don't define this macro, nothing special is output to
  1049.      arrange to call the function.  This is correct when the function
  1050.      will be called in some other manner--for example, by means of the
  1051.      `collect2' program, which looks through the symbol table to find
  1052.      these functions by their names.
  1053.  
  1054. `ASM_OUTPUT_DESTRUCTOR (STREAM, NAME)'
  1055.      This is like `ASM_OUTPUT_CONSTRUCTOR' but used for termination
  1056.      functions rather than initialization functions.
  1057.  
  1058.      When `ASM_OUTPUT_CONSTRUCTOR' and `ASM_OUTPUT_DESTRUCTOR' are
  1059.      defined, the initializaiton routine generated for the generated
  1060.      object file will have static linkage.
  1061.  
  1062.    If your system uses `collect2' as the means of processing
  1063. constructors, then that program normally uses `nm' to scan an object
  1064. file for constructor functions to be called.  On such systems you must
  1065. not define `ASM_OUTPUT_CONSTRUCTOR' and `ASM_OUTPUT_DESTRUCTOR' as the
  1066. object file's initialization routine must have global scope.
  1067.  
  1068.    On certain kinds of systems, you can define these macros to make
  1069. `collect2' work faster (and, in some cases, make it work at all):
  1070.  
  1071. `OBJECT_FORMAT_COFF'
  1072.      Define this macro if the system uses COFF (Common Object File
  1073.      Format) object files, so that `collect2' can assume this format
  1074.      and scan object files directly for dynamic constructor/destructor
  1075.      functions.
  1076.  
  1077. `OBJECT_FORMAT_ROSE'
  1078.      Define this macro if the system uses ROSE format object files, so
  1079.      that `collect2' can assume this format and scan object files
  1080.      directly for dynamic constructor/destructor functions.
  1081.  
  1082.      These macros are effective only in a native compiler; `collect2' as
  1083.      part of a cross compiler always uses `nm' for the target machine.
  1084.  
  1085. `REAL_NM_FILE_NAME'
  1086.      Define this macro as a C string constant containing the file name
  1087.      to use to execute `nm'.  The default is to search the path
  1088.      normally for `nm'.
  1089.  
  1090.      If your system supports shared libraries and has a program to list
  1091.      the dynamic dependencies of a given library or executable, you can
  1092.      define these macros to enable support for running initialization
  1093.      and termination functions in shared libraries:
  1094.  
  1095. `LDD_SUFFIX'
  1096.      Define this macro to a C string constant containing the name of the
  1097.      program which lists dynamic dependencies, like `"ldd"' under SunOS
  1098.      4.
  1099.  
  1100. `PARSE_LDD_OUTPUT (PTR)'
  1101.      Define this macro to be C code that extracts filenames from the
  1102.      output of the program denoted by `LDD_SUFFIX'.  PTR is a variable
  1103.      of type `char *' that points to the beginning of a line of output
  1104.      from `LDD_SUFFIX'.  If the line lists a dynamic dependency, the
  1105.      code must advance PTR to the beginning of the filename on that
  1106.      line.  Otherwise, it must set PTR to `NULL'.
  1107.  
  1108.